<%--
  Created by IntelliJ IDEA.
  User: 贾振鹏
  Date: 2021/5/28
  Time: 9:47
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
    <meta name="renderer" content="webkit">
    <title>角色列表展示页面</title>
    <link rel="stylesheet" href="${css}/pintuer.css">
    <link rel="stylesheet" href="${css}/admin.css">
    <script src="${js}/jquery.js"></script>
    <script src="${js}/pintuer.js"></script>
</head>
<body>
<div class="panel admin-panel">
    <div class="panel-head"><strong class="icon-reorder"> 内容列表</strong></div>
    <table class="table table-hover text-center">
        <tr>
            <th width="5%">ID</th>
            <th width="10%">角色名称</th>
            <th width="10%">操作</th>
        </tr>
        <tbody>
        <c:forEach items="${roleList}" var="role" varStatus="v">
            <tr>
                <td>${v.count}</td>
                <td>${role.rolename}</td>
                <td>
                    <div class="button-group">
                        <shiro:hasPermission name="admin:role:editview">
                            <a class="button border-main" href="${root}/admin/role/editview?id=${role.id}"><span class="icon-edit"></span> 修改</a>
                        </shiro:hasPermission>
                        <shiro:hasPermission name="admin:role:deleteview">
                            <a class="button border-red delrole" href="javascript:void(0)" name="${role.id}" ><span class="icon-trash-o"></span> 删除</a>
                        </shiro:hasPermission>
                    </div>
                </td>
            </tr>
        </c:forEach>

        </tbody>
    </table>
</div>
<script type="text/javascript">
    $(function(){
        $(".delrole").click(function () {
            if(!confirm("是否要删除？")){
                return;
            }
            var obj = $(this);
            var id = $(this).attr("name");
            $.get("${root}/admin/role/delete",
                {"id":id},
                function (data) {
                    if(data.code==200){
                        obj.parent().parent().parent().remove();
                        return;
                    }else{
                        alert(data.msg);
                    }
                },"json");
        });
    })

</script>

</body>
</html>
